<!--
 * @Author: liuyonghu liuyonghu
 * @Date: 2024-06-15 10:06:20
 * @LastEditors: liuyonghu liuyonghu
 * @LastEditTime: 2024-11-13 18:14:25
 * @FilePath: /demos/source/remote source/one.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <img crossorigin src="https://puui.qpic.cn/vcover_vt_pic/0/mzc00200xf3rir61687481062678/0" alt="" srcset="">
  <script>
    localStorage.setItem("time", Date.now())

    function createTracingProxy(target) {
      const calls = [];

      const handler = {
        apply(target, thisArg, argumentsList) {
          const methodCall = { target: target.name, arguments: argumentsList };
          calls.push(methodCall);
          const result = target.apply(thisArg, argumentsList);
          return result;
        }
      };

      const proxy = new Proxy(target, handler);

      proxy.getCalls = () => calls;

      return proxy;
    }

    // 示例用法
    function multiply(x, y) {
      return x * y;
    }

    function add(x, y) {
      return x + y;
    }

    const tracedMultiply = createTracingProxy(multiply);
    const tracedAdd = createTracingProxy(add);

    tracedMultiply(3, 4);
    tracedAdd(tracedMultiply(3, 4), 5);

    const callChain = tracedAdd.getCalls();
    console.log(callChain);
  </script>
</body>

</html>